let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n182,
  i =
    (this && this.__extends) ||
    ((_n182 = function n(t, e) {
      return (_n182 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n182(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.UiWeaponEffect = void 0);
var r = t('UIComponent'),
  a = t('ComUtils'),
  s = t('TimeMrg'),
  c = t('MathUtils'),
  l = t('ResMrg'),
  u = t('BattleScene'),
  h = t('CivilizationMrg'),
  p = t('BattleUtils'),
  f = t('BattleMrg'),
  d = (function (t) {
    function e() {
      var e = t.call(this, cc.Canvas.instance.node) || this,
        o = e;
      return (
        cc.resources.load('Prefab/Effect/UiWeaponEffect', function (t, e) {
          t || o.initEffect(cc.instantiate(e));
        }),
        e
      );
    }
    return (
      i(e, t),
      (e.show = function (t) {
        t && (this.list.length ? this.list.shift() : new e()).showEffect(t);
      }),
      (e.put = function (t) {
        this.list.push(t);
      }),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this), this.removeListenerTouch();
      }),
      (e.prototype.initEffect = function (t) {
        (this._node = t),
          (this._imgIcon = a.default.getComponent(cc.Sprite, t, 'imgIcon')),
          (this._msTrailing = a.default.getComponent(
            cc.MotionStreak,
            t,
            'msTrailing'
          )),
          this.loadWeapon(),
          this.show();
      }),
      (e.prototype.showEffect = function (t) {
        (this._item = t), this._node && (this.loadWeapon(), this.show());
      }),
      (e.prototype.loadWeapon = function () {
        if (this._item.data) {
          var t = c.default.clamp(
              this._item.data.level - h.CivilizationMrg.ins.level + 1,
              1,
              6
            ),
            o = e.Colors[this._item.data.type][t];
          (this._node.scale = 0.2),
            (this._msTrailing.stroke = 0.2 * this._imgIcon.node.width),
            (this._msTrailing.color = cc.Color.fromHEX(
              this._msTrailing.color,
              o
            )),
            l.ResMrg.loadSpriteByAtlas(
              this._imgIcon,
              'Atlas/Battle',
              this._item.data.icon
            );
        } else this.complete();
      }),
      (e.prototype.createPath = function () {
        var t,
          o = this._item.view.convertToWorldSpaceAR(cc.Vec2.ZERO);
        (t = this._item.soldier
          ? this._item.soldier.entity.convertToWorldSpaceAR(e.mount)
          : u.BattleScene.ins.entity.convertToWorldSpaceAR(
              cc.v2(
                p.default.ColStart + this._item.col * p.default.ColSpace,
                p.default.RowStart - this._item.row * p.default.RowSpace
              )
            )),
          (o = this.view.convertToNodeSpaceAR(o)),
          (t = this.view.convertToNodeSpaceAR(t));
        var n = Math.random() > 0.5 ? 1 : -1;
        o.x < -150 ? (n = 1) : o.x > 150 && (n = -1);
        var i = cc.v2(
          o.x + n * c.default.randomInt(100, 200),
          t.y + c.default.randomInt(400, 600)
        );
        return c.default.bezier2([o, i, t], 20);
      }),
      (e.prototype.onShow = function () {
        t.prototype.onShow.call(this),
          (this._speed = 200 * c.default.randomInt(8, 12)),
          (this._path = this.createPath()),
          this.next(),
          this.view.addChild(this._node),
          s.TimeMrg.timer.add(this.update, this);
      }),
      (e.prototype.next = function () {
        var t = this._node;
        if (
          (t.setPosition(this._path[0]),
          this._path.shift(),
          this._path.length > 0)
        ) {
          var e = this._path[0];
          (this._radian = Math.atan2(e.y - t.y, e.x - t.x)),
            (this._distance = c.default.distance2(t.x, t.y, e.x, e.y)),
            (t.angle = this._radian * c.default.Rad2Deg);
        } else this.complete();
      }),
      (e.prototype.onUpdate = function (e) {
        t.prototype.onUpdate.call(this, e);
        var o = e * this._speed;
        (this._distance -= o),
          this._distance > 0 ? this.updateLocation(o) : this.next(),
          (this._speed *= 1.02);
      }),
      (e.prototype.onClose = function () {
        t.prototype.onClose.call(this),
          s.TimeMrg.timer.remove(this.update, this),
          (this._item = null),
          this._node && (this._node.parent = null),
          this._weapon &&
            (this._weapon.removeFromParent(!0), (this._weapon = null)),
          e.put(this);
      }),
      (e.prototype.updateLocation = function (t) {
        var e = this._node,
          o = c.default.to(e.x, e.y, this._radian, t);
        e.setPosition(o);
      }),
      (e.prototype.complete = function () {
        this._item.emit(f.BattleEvent.SoldierChanged, this._item), this.close();
      }),
      (e.Colors = [
        [
          '#FFFFFF',
          '#FFFFFF',
          '#FFFFFF',
          '#FFFFFF',
          '#FFFFFF',
          '#FFFFFF',
          '#FFFFFF'
        ],
        [
          '#FFFFFF',
          '#ffffff',
          '#fef1ef',
          '#fde4e0',
          '#fcd7d2',
          '#fbcbc5',
          '#fac0b9'
        ],
        [
          '#FFFFFF',
          '#b4fcff',
          '#b4fcff',
          '#b4f2ff',
          '#b4edff',
          '#b4e8ff',
          '#b4e3ff'
        ],
        [
          '#FFFFFF',
          '#fec049',
          '#feb449',
          '#fea849',
          '#fe9c49',
          '#fe9049',
          '#fe8449'
        ]
      ]),
      (e.mount = cc.v2(0, 100)),
      (e.list = []),
      e
    );
  })(r.UIComponent);
(o.UiWeaponEffect = d), console.log('end');
module.exports = e.exports;
